const mysql = require('mysql');
var connect = mysql.createConnection({
    host: "120.78.71.180",
    port: 3306,
    user: 'mpmaoyan',
    password: '123456',
    database: "mpmaoyan",
});

connect.connect(function (err) {
    if (err) {
        console.log('连接mysql数据库失败：',err);
        throw err;
    }
});

//导出模块
function query(sql) {
    return new Promise((resolve, reject) => {
        connect.query(sql, (err, rows, fields) => {
            if (err) {
                reject(err)
            }
            resolve(rows)
        })
    })
}

module.exports =  {
    query, connect
}

